﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;
namespace chatblog.login
{
    public partial class biaozhuntie : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                cbuser.dealcookie();
                dealrequest();
                bind1();
                //bind2();
                //bind3();
            }
        }
        /// <summary>
        /// 绑定
        /// </summary>
        private void bind1()
        {
            DataTable a1;
            string sql = "";
            //个人发帖
            sql = " select count(*) from cblist where cbstatus = '有效' "
                + " and cbuserid = '" + AliApi.appUserId + "' and cblisttype = '发帖'";
                //+ " and jccreatedate <= '" + DateTime.Today.AddDays(1).ToShortDateString()
                //+ "' and jccreatedate >= '" + DateTime.Today.ToShortDateString() + "' ";
            a1 = RuleCode.Common.SqlHelper.Instance.ExecuteQuery(sql).Tables[0];
            Label4.Text = a1.Rows[0].ItemArray[0].ToString();
            //个人回帖
            sql = " select count(*) from cblist where cbstatus = '有效' "
                + " and cbuserid = '" + AliApi.appUserId + "' and cblisttype = '回帖'";
                //+ " and jccreatedate <= '" + DateTime.Today.ToShortDateString()
                //+ "' and jccreatedate >= '" + DateTime.Today.AddDays(-1).ToShortDateString() + "' ";
            a1 = RuleCode.Common.SqlHelper.Instance.ExecuteQuery(sql).Tables[0];
            Label5.Text = a1.Rows[0].ItemArray[0].ToString();
            //个人标准总量
            Label6.Text=(zfunction.str2int(Label4.Text) + zfunction.str2int(Label5.Text) * 0.2).ToString();

            if (TextBox1.Text.Replace("'", "").Trim() != "")
            {
                string cataid = TextBox1.Text.Replace("'", "").Trim();
                //模块发帖
                sql = " select count(*) from cblist where cbstatus = '有效' ";
                sql += " and cbcataid in ( select cbcataid from cbcata where cbcataid='"
                    + cataid + "' "
                    + " or pid1='" + cataid + "' "
                    + " or pid2='" + cataid + "' "
                    + " or pid3='" + cataid + "' "
                    + " or pid4='" + cataid + "' ) "
                    ;
                sql += " and cblisttype = '发帖'";
                a1 = RuleCode.Common.SqlHelper.Instance.ExecuteQuery(sql).Tables[0];
                Label1.Text = a1.Rows[0].ItemArray[0].ToString();
                //模块回帖
                sql = " select count(*) from cblist where cbstatus = '有效' ";
                sql += " and cbcataid in ( select cbcataid from cbcata where cbcataid='"
                    + cataid + "' "
                    + " or pid1='" + cataid + "' "
                    + " or pid2='" + cataid + "' "
                    + " or pid3='" + cataid + "' "
                    + " or pid4='" + cataid + "' ) "
                    ;
                sql += " and cblisttype = '发帖'";
                a1 = RuleCode.Common.SqlHelper.Instance.ExecuteQuery(sql).Tables[0];
                Label2.Text = a1.Rows[0].ItemArray[0].ToString();
                //模块标准总量
                Label3.Text = (zfunction.str2int(Label1.Text) + zfunction.str2int(Label2.Text) * 0.2).ToString();
            }



        }

        private void dealrequest()
        {
            if (AliApi.appUserId == "")
            {
                Response.Redirect("login.aspx?redirecturl=" + "nickname.aspx");
            }
        }
        protected void Button_sel_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(this.Button_sel, this.Button_sel.GetType(), "selectbuttonclick",
"<script type =\"text/javascript\" >selectButtonClick('" + this.TextBox1.ClientID + "');</script>", false);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            bind1();
        }
    }
}
